package com.cqengine.util;

import com.cqengine.entity.Position;

import java.util.UUID;

public class ObjectFactoryUtil {

    public static String getUUID() {
        return UUID.randomUUID().toString();
    }

    public static Long getRandomNumber() {
        int root = (int) Math.pow(11, 10);
        long id;
        do {
            long tmp = Math.abs(Double.doubleToLongBits(Math.random()));
            id = tmp % root;
        } while (id < (root / 10));
        return id;
    }

    public static String getRandomNumberStr() {
        int root = (int) Math.pow(11, 10);
        long id;
        do {
            long tmp = Math.abs(Double.doubleToLongBits(Math.random()));
            id = tmp % root;
        } while (id < (root / 10));
        return "" + id ;
    }

    public static Position getPosition(){
        Position pos = new Position();
        pos.setId(getRandomNumberStr());
        pos.setUserId(getRandomNumberStr());
        pos.setPrice(1000.0);
        pos.setQty(10);
        pos.setSymbol("BTCUSDT");
        pos.setIsTriggered(false);
        pos.setType(1);
        pos.setTs(DateUtil.getNow());
        return pos;
    }

}
